﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Utils;

public partial class credit_index : FBasePage
{
    // Fields

    public Maticsoft.BLL.orderdetail detailbll = new Maticsoft.BLL.orderdetail();
    public List<Maticsoft.Model.orderdetail> detaillist = new List<Maticsoft.Model.orderdetail>();
    public Maticsoft.BLL.Flow flowbll = new Maticsoft.BLL.Flow();
    public List<Maticsoft.Model.Flow> flowlist = new List<Maticsoft.Model.Flow>();
    public Maticsoft.Model.Flow flowmodel = new Maticsoft.Model.Flow();

    public Maticsoft.BLL.Invite invitebll = new Maticsoft.BLL.Invite();
    public Maticsoft.Model.Invite invitemodel = new Maticsoft.Model.Invite();

    public Maticsoft.BLL.Order orderbll = new Maticsoft.BLL.Order();
    public List<Maticsoft.Model.Order> orderlist = new List<Maticsoft.Model.Order>();
    public Maticsoft.Model.Order ordermodel = new Maticsoft.Model.Order();
    public string pagenum = "1";
    public string strpage;
    public Maticsoft.BLL.System sysbll = new Maticsoft.BLL.System();
    public Maticsoft.Model.System sysmodel = new Maticsoft.Model.System();
    public Maticsoft.BLL.UserInfo userbll = new Maticsoft.BLL.UserInfo();
    public Maticsoft.Model.UserInfo usermodel = new Maticsoft.Model.UserInfo();

    // Methods
    public string Getname(string orderid)
    {
        string username = "";
        if (this.orderbll.GetOrderid(orderid) != null)
        {
            int id = int.Parse(this.orderbll.GetOrderid(orderid).User_id.ToString());
            Maticsoft.Model.UserInfo model = this.userbll.GetModel(id);
            if (model != null)
            {
                username = model.Username;
            }
        }
        return username;
    }

    public string GetTeam(string id, string orderid)
    {
        string str = "";
        Maticsoft.Model.Team model = new Maticsoft.Model.Team();
        Maticsoft.BLL.Team team2 = new Maticsoft.BLL.Team();
        model = team2.GetModel(Convert.ToInt32(id));
        if (model != null)
        {
            return string.Concat(new object[] { "<a href='../team.aspx?id=", model.Id, "' target=_blank>", model.Title, "</a>" });
        }
        this.detaillist = this.detailbll.Searchorderdetail(Convert.ToInt32(orderid));
        int num = 0;
        foreach (Maticsoft.Model.orderdetail orderdetail in this.detaillist)
        {
            num++;
            object obj2 = str;
            str = string.Concat(new object[] { obj2, "<a href='../team.aspx?id=", orderdetail.Teamid, "' target=_blank>", num, ":" });
            str = str + ((team2.GetModel(Convert.ToInt32(orderdetail.Teamid)) == null) ? "" : team2.GetModel(Convert.ToInt32(orderdetail.Teamid)).Title);
            str = str + "</a><br>";
        }
        return str;
    }

    public void GetUserfee()
    {
        int num;
        this.usermodel = this.userbll.Getusername(base.UserName);
        this.sysmodel = this.sysbll.GetModel(this.userbll.Getuserid(base.UserName));
        this.flowlist = this.flowbll.SearchFlow(30, Convert.ToInt32(this.pagenum), "*", "Create_time desc", "User_id=" + this.userbll.Getuserid(base.UserName), out num);
        if (this.flowlist.Count == 0)
        {
            this.strpage = "对不起，没有相关数据";
        }
        else if (num >= 30)
        {
            this.strpage = this.flowbll.GetflowPageStr(num, Convert.ToInt32(this.pagenum), 30);
        }
    }

    protected override void OnLoad(EventArgs e)
    {
        if (!(this.Page.User.Identity.IsAuthenticated && !(this.Page.User.Identity.Name == "")))
        {
            base.Response.Redirect("/account/Login.aspx");
        }
        base.OnLoad(e);
        this.MyWebside1.Select = "credit";
        if (base.Request["pgnum"] != null)
        {
            if (Utility.IsNum(base.Request["pgnum"].ToString()))
            {
                this.pagenum = base.Request["pgnum"].ToString();
            }
            else
            {
                this.SetError("您输入的参数非法");
            }
        }
        this.GetUserfee();
    }

}